Skip to content

Add Hex Coordinates #1

Open
timskap wants to merge 5 commits into
bdotdub:masterfrom
timskap:master
Open

Add Hex Coordinates #1
timskap wants to merge 5 commits into
bdotdub:masterfrom
timskap:master

Conversation

@timskap

@timskap timskap commented Mar 15, 2024

Copy link
Copy Markdown

Example:


struct HashableCLLocationCoordinate2D: Hashable {
    let latitude: Double
    let longitude: Double
    
    init(_ coordinate: CLLocationCoordinate2D) {
        self.latitude = coordinate.latitude
        self.longitude = coordinate.longitude
    }
}

let resolution = 5
            let ringSize = 30
            let h3Index = H3Index(coordinate: H3Coordinate(lat: locationCoordinate.latitude, lon: locationCoordinate.longitude), resolution: Int32(resolution))
            let ringIndexes = h3Index.kRingIndices(ringK: Int32(ringSize))
            
            hexCoordinates = ringIndexes.map { index in
                let coordinates = index.boundary()
                return coordinates.map { coordinate in
                    HashableCLLocationCoordinate2D(CLLocationCoordinate2D(latitude: coordinate.lat, longitude: coordinate.lon))
                }
            }

@plz-review

plz-review Bot commented Mar 15, 2024

Copy link
Copy Markdown

Plz Review!
Review this PR using plz

@timskap

timskap commented May 23, 2025

Copy link
Copy Markdown
Author

I fix an issue with stdrup in file. Should work now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants